<template>
    <view>
        <index-home v-if="PageCur=='index-home'" class="content" ref="indexhome"></index-home>
        <!-- <book-publish v-if="PageCur=='book-publish'" class="content"></book-publish> -->
        <user-home v-if="PageCur=='user-home'" class="content"></user-home>

        <view class="cu-bar tabbar bg-white shadow foot">
            <view class="action" @click="NavChange" data-cur="index-home">
                <view class='cuIcon-cu-image'>
                    <image :src="'../../static/tabBar/index-home' + [PageCur=='index-home'?'_cur':''] + '.png'"
                        mode="aspectFill"></image>
                </view>
                <view :class="PageCur=='index-home'?'text-red':'text-black'">推荐</view>
            </view>
            <!-- <view class="action text-black add-action" @click="NavChange" data-cur="book-publish">
                <button class="cu-btn cuIcon-add bg-red shadow"></button>
                发布
            </view> -->
            <view class="action" @click="NavChange" data-cur="user-home">
                <view class='cuIcon-cu-image'>
                    <image :src="'../../static/tabBar/user-home1' + [PageCur=='user-home'?'_cur':''] + '.png'"
                        mode="aspectFill"></image>
                </view>
                <view :class="PageCur=='user-home'?'text-red':'text-black'">我的</view>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                PageCur: 'index-home'
            }
        },
        onReachBottom() {
            console.log('index-home onReachBottom')
            if (this.PageCur == 'index-home') {
                this.$refs.indexhome.reachBottom();
            }
        },
        mounted() {
        },
        methods: {
            NavChange: function(e) {
                if (e.currentTarget.dataset.cur == 'book-publish') {
                    uni.navigateTo({
                        url: "/pages/book/publish"
                    })
                    return;
                }
                this.PageCur = e.currentTarget.dataset.cur
            }
        },
        onShareAppMessage: function(t) {
            return t.from, {
                title: "辅食宝典",
                path: "/pages/home/home?&openid=" + uni.getStorageSync("share_openid"),
                imageUrl: "https://jzy-sup3-dev.oss-cn-shanghai.aliyuncs.com/chik/static/share_logo.jpg"
            };
        }
    }
</script>

<style>
    .content {
        background-color: #FFFFFF;
        margin-bottom: 100rpx;
    }
</style>
